#include"processbar.h"
//version1
//const char *lable="|/-\\";
//void process()
//{
//char buffer[NUM];
//memset(buffer,'\0',sizeof(buffer));
//int cnt =0;
//buffer[0]=Head;
//while(cnt<=100)
//{
//printf("[%-100s][%3d%%][%c]\r",buffer,cnt,lable[cnt%4]);
//fflush(stdout);
//
//buffer[cnt++]=Body;
//if(cnt!=100)
//buffer[cnt]=Head;
//
//usleep(5000);
//}
//printf("\n");
//}
//version2

char buffer[NUM];
const char *lable="|/-\\";
void process_flush(double rate)
{
static int cnt =0;
if(rate<=1.0)buffer[0]=Head;
cnt++;
buffer[(int)rate]=Body;
if((int)rate<100)
buffer[(int)rate+1]=Head;

cnt%=4;
printf("[%-100s][%.1f%%][%c]\r",buffer,rate,lable[cnt%4]);
fflush(stdout);
}
